<?php
namespace TinyPHP;
/*
 *
 * 路由
 * Created by tiny
 * User: tiny
 * Date: 16/06/23
 * E-mail: mountaingiant@163.com
 *
 * */
 class Route{
     /*
      * 分析URL
      * */
     public function parse(){
         $pathInfo = !empty($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : array();
         $appName = !empty($pathInfo[1]) ? $pathInfo[1] : getConfig('DEFAULT_APP_NAME');
         $className = !empty($pathInfo[2]) ? $pathInfo[2] : getConfig('DEFAULT_CONTROLLER');
         $methodName = !empty($pathInfo[3]) ? $pathInfo[3] : getConfig('DEFAULT_METHOD');
         $c = $appName.'\Controller\\'.$className.'Controller';
         $obj = new $c();
         $obj->$methodName();
     }
 }

